<%@page language="java" contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" %>
<%@include file="../../common/dqdp_common.jsp" %>
<%
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
//    if(request.getProtocol().split("\\/").equals("http")){
//        response.sendRedirect("https://"+request.getRequestURI());
//    };
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <link href="${baseURL}/themes/${style}/css/login.css" rel="stylesheet" type="text/css"/>
    <link href="${baseURL}/themes/${style}/css/bass.css" rel="stylesheet" type="text/css"/>
    <script src="${baseURL}/js/do1/common/jquery-1.6.3.min.js"></script>
    <script src="${baseURL}/js/do1/common/common.js?ver=<%=jsVer%>"></script>
    <script src="${baseURL}/js/3rd-plug/jquery/jquery.form.js"></script>

    <!--
   按钮函数 -->

</head>
<body>
<script type="text/javascript">

    var lastError = "${sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message}";
    if (lastError)alert("${sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message}");
</script>
<form id="id_form_login" action="${baseURL}/j_spring_security_check" method="post" autocomplete="off">
    <input type='hidden' name='_spring_security_remember_me' value="true" />
    <input type='hidden' name='dqdp_csrf_token' value="${sessionScope.dqdp_csrf_token}" />
    <div class="loginDiv">
        <div class="h130 overflow"></div>
        <ul class="overflow lh30 h50">
            <li class="w170 h30 f_black fcolor_3d79ae f20 tr fleft mr10">帐号：</li>
            <li class="fleft w300">
                <input type="text" name="j_username" value="admin" id="j_username" class="w280 p6" onkeydown="onKeyUp(event)" valid='{"must":true,"tip":"帐号"}' value='${sessionScope['SPRING_SECURITY_LAST_USERNAME']}'/>
            </li>
        </ul>
        <ul class="overflow lh30 h50">
            <li class="w170 h30 f_black fcolor_3d79ae f20 tr fleft mr10">密码：</li>
            <li class="fleft w300">
                <input type="password" name="j_password" id="j_password" value="test" class="w280 p6" valid="{must:true,tip:'密码'}" onkeydown="onKeyUp(event)"/>
            </li>
        </ul>
        <ul class="overflow lh30 h50">
            <li class="w170 h30 fleft mr10"></li>
            <li class="fleft w300 overflow">
                <a href="javascript:doLogin()" class="login_btn fleft mr30"></a>
                <a href="javascript:doLoginTest()" class="reset_btn fleft"></a>
                <a href="javascript:doAjaxLogin()">AJAX登陆</a>
            </li>
        </ul>
    </div>

</form>
</body>
</html>
<script type="text/javascript">
    $(document).ready(function(){
        doLogin();
    });

    function onKeyUp(event) {
        var e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13)doLogin();
    }
    function doLogin() {
        var dqdp = new Dqdp();
        if (dqdp.submitCheck("id_form_login"))
            document.getElementById("id_form_login").submit();
    }
    function doLoginTest() {
        $("#j_username").val("");
        $("#j_password").val("");
    }

    var _topDocument = getTopFrame(this).parent.document;
    if (_topDocument != document)
        _topDocument.location.href = "${baseURL}/jsp/default/login/login_in.jsp";
    function getTopFrame($win) {
        var pw = getWindowOpener($win);
        if (undefined != pw)
            $win = getTopFrame(pw);
        return $win;
    }


    function getWindowOpener($win) {
        return $win.opener;
    }

    function doAjaxLogin() {
        $('#id_form_login').ajaxSubmit({
            dataType:'json',
            success:function (result) {
                alert(result.desc);
            },
            error:function(result){
                alert("通讯故障");
            }
        });
    }
</script>